package com.firmail;

import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.cloud.client.circuitbreaker.EnableCircuitBreaker;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
import org.springframework.cloud.netflix.feign.EnableFeignClients;
import org.springframework.cloud.netflix.hystrix.dashboard.EnableHystrixDashboard;
import org.springframework.context.annotation.Bean;
import org.springframework.transaction.annotation.EnableTransactionManagement;
import org.springframework.web.filter.CharacterEncodingFilter;

@SpringBootApplication/*(exclude = {DataSourceAutoConfiguration.class, HibernateJpaAutoConfiguration.class})*/
@EnableEurekaClient
@EnableFeignClients
/*@EnableHystrixDashboard
@EnableHystrix*/ //Ribbon,需要这两个注解和@HystrixCommand(fallbackMethod = "hiError")
@EnableHystrixDashboard
@EnableCircuitBreaker
@MapperScan("com.firmail.dao")
//@Component
@EnableTransactionManagement
@RefreshScope
public class FirmailIndexApplication {

    public static void main(String[] args) {
        SpringApplication.run(FirmailIndexApplication.class, args);
    }


    @Bean
    public FilterRegistrationBean filterRegistrationBean() {
        FilterRegistrationBean registrationBean = new FilterRegistrationBean();
        CharacterEncodingFilter characterEncodingFilter = new CharacterEncodingFilter();
        characterEncodingFilter.setForceEncoding(true);
        characterEncodingFilter.setEncoding("UTF-8");
        registrationBean.setFilter(characterEncodingFilter);
        return registrationBean;
    }

}
